package baidu.com.matedemo.base;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import com.baidu.duer.libcore.adapter.CommonAdapter;

import baidu.com.matedemo.R;

/**
 * Created by niufei01 on 2017/12/29.
 */

public abstract class ListBaseFragment extends BaseFragment implements AdapterView.OnItemClickListener{
    private ListView listview;

    @Override
    public View onCreateContentViewCompat(LayoutInflater inflater, ViewGroup viewGroup, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.layout_listview, viewGroup, false);
    }

    @Override
    public void onContentViewCreated(View view) {
        listview = (ListView) view.findViewById(R.id.listview);
        onViewCreated(listview);
        listview.setOnItemClickListener(this);
    }

    public abstract void onViewCreated(View view);

    public void setAdapter(CommonAdapter adapter) {
        listview.setAdapter(adapter);
        adapter.notifyDataSetChanged();
    }

    public ListView getListView() {
        return listview;
    }
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

    }
}
